<?php

namespace App\Dao\Mongodb;

use App\Actions\MessageAction;
use App\Dao\ClosenessDao;
use App\Dao\UserDao;
use App\Dao\UserRemarkDao;
use App\Model\User;
use App\Model\UserRemark;
use App\Utils\LoggerUtil;
use App\Utils\MongoDBClient;
use Hyperf\Context\ApplicationContext;
use Throwable;

class UserChatFlagDao
{
    private static $instance;

    public static function getInstance()
    {
        if (!self::$instance) {
            self::$instance = Applicationcontext::getcontainer()->get(self::class);
        }
        return self::$instance;
    }

    public function updateLastTimeFlag($uid, $imei, $micotime)
    {
        $mon = MongoDBClient::getInstance();
        $lastMsgWhere['uid'] = (int)$uid;
        $lastMsgWhere['unique'] = (string)$imei;
        $thisMsgModify['last_time'] = $micotime;
        $thisMsgModify = array_merge($lastMsgWhere, $thisMsgModify);
        return $mon->update('tb_user_chat_flag', $lastMsgWhere, $thisMsgModify, false, true);

        // $mon = new MonDB();
        // //查找上次拉取数据之后的数据
        // $lastMsgWhere['uid'] = (int)$uid;
        // $lastMsgWhere['unique'] = (string)$imei;
        // //使用毫秒级
        // $thisMsgModify['last_time'] = $micotime;
        // $thisMsgModify = array_merge($lastMsgWhere, $thisMsgModify);
        // return $mon->update($lastMsgWhere, $thisMsgModify, MON_USER_CHAT_FLAG, false, true);
    }

}